package com.fjec.market.controller;

import com.fjec.common.protocol.JsonResult;
import com.fjec.market.service.IBizOrderComplaintService;
import org.omg.CORBA.INTERNAL;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 046.订单投诉表 前端控制器
 * </p>
 *
 * @author admin
 * @since 2020-09-21
 */
@RestController
@RequestMapping("/")
public class BizOrderComplaintController {

    @Resource
    private IBizOrderComplaintService service;


    /**
     * 订单投诉
     *
     * @param id      子订单Id
     * @param context 投诉内容
     * @param contact 联系人
     * @param phone   联系电话
     * @param picIds  照片附件Id列表
     * @param picUrls 照片附件url
     * @return
     */
    @PostMapping("/y/phy/order/sub/complaint")
    public JsonResult subOrderComplaint(Long id, String context, String contact, String phone,
                                        @RequestParam(required = false) String picIds,
                                        @RequestParam(required = false) String picUrls) {
        return service.subOrderComplaint(id, context, contact, phone, picIds, picUrls);
    }

    /**
     * devops 投诉列表
     * @param searchBy
     * @param title
     * @param busiType
     * @param markCode
     * @param orderType
     * @param handleResult
     * @param startTime
     * @param endTime
     * @return
     */
    @GetMapping("/y/phy/order/complaint/getComplaintsByConditions")
    public JsonResult getComplaintsByConditions(@RequestParam(required = false) Integer searchBy,
                                                @RequestParam(required = false) String title,
                                                @RequestParam(required = false) Integer busiType,
                                                @RequestParam(required = false) Integer markCode,
                                                @RequestParam(required = false) Integer orderType,
                                                @RequestParam(required = false) Integer handleResult,
                                                @RequestParam(required = false) String startTime,
                                                @RequestParam(required = false) String endTime) {
        List<Map<String, Object>> result = service.getComplaintsByConditions(searchBy, title, busiType, markCode, orderType, handleResult, startTime, endTime);
        return JsonResult.success().data(result).build();
    }

    /**
     * devops 处理投诉
     * @param subOrderId
     * @return
     */
    @PostMapping("/phy/order/complaint/handle")
    public Integer handleComplaint(Long orderId, Long subOrderId, Long complaintId,
                                   Integer handleType, String amount, String complaintText) {
        int result = service.handleComplaint(orderId, subOrderId, complaintId, handleType, amount, complaintText);
        return result;
    }
}
